home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / VOL_400 / 446_01 / DOC / SPLINES / EX / PROG6.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-18  |  828 b   |  28 lines

  1. // ******************* File: prog6.C *****************
  2. // Using Interpolation function in ParametricTPSurface
  3. #include <ParametricTPSurface.h>
  4. #include <splineOutput.h>
  5.  
  6. int main()
  7. {
  8.   const real Pi=M_PI;  // M_PI is found in math.h (3.14159....)
  9.   // generate points on a surface:
  10.   Mat(real) xm(29,5), ym(29,5), zm(29,5); // (xm,ym,zm) coord. of a point
  11.   real theta, phi;
  12.   for (int i=1; i<=29; i++)
  13.     {
  14.      theta=(i-1)*Pi/8;
  15.       for (int j=1; j<=5; j++)
  16.         {
  17.            phi=(j+3)*Pi/4;
  18.            xm(i,j)=(800-(i-1)*25+200*cos(phi))*cos(theta)+1000;
  19.            ym(i,j)=(800-(i-1)*25+200*cos(phi))*sin(theta)+1000;
  20.            zm(i,j)=200*sin(phi)+200;
  21.         }
  22.     }
  23.   ParametricTPSurface ptps;
  24.   ptps.interpolation(xm,ym,zm,4,4,"Uniform","Uniform");
  25.   createMathFile(ptps,1,1,"FILE=surface3.math");
  26.   return 0;
  27. }
  28.